import { BasicColumn, FormSchema } from '/@/components/Table';
import { render } from '/@/utils/common/renderUtils';

export const columns: BasicColumn[] = [
  {
    title: 'TraceId',
    dataIndex: 'traceId',
    width: 120,
    align: 'left',
  },
  {
    title: '任务名称',
    dataIndex: 'jobName',
    width: 120,
    align: 'left',
  },
  {
    title: '任务组名',
    dataIndex: 'jobGroup',
    width: 100,
    align: 'left',
    customRender: ({ text }) => {
      return render.renderDict(text, 'sys_job_group')
    },
  },
  {
    title: '调用目标',
    dataIndex: 'invokeTarget',
    width: 150,
    align: 'left',
  },
  {
    title: '日志信息',
    dataIndex: 'jobMessage',
    width: 200,
    align: 'left',
  },
  
  // {
  //   title: '参数',
  //   dataIndex: 'parameter',
  //   width: 200,
  // },
  // {
  //   title: '描述',
  //   dataIndex: 'remark',
  //   width: 100,
  // },
  {
    title: '执行状态',
    dataIndex: 'status',
    width: 100,
    customRender: ({ text }) => {
      const color = text == '1' ? 'red' : text == '0'? 'green': 'gray';
      return render.renderTag(render.renderDict(text, 'quartz_status'),color)
    },
  },
  {
    title: '创建时间',
    dataIndex: 'createdAt',
    width: 160,
  },
];

export const searchFormSchema: FormSchema[] = [
  {
    field: 'status',
    label: '任务状态',
    component: 'JDictSelectTag',
    componentProps: {
      dictCode: 'quartz_status',
      stringToNumber: true,
    },
    colProps: { span: 8 },
  },
  {
    field: 'fieldTime',
    component: 'RangePicker',
    label: '创建时间',
    componentProps: {
      valueType: 'Date',
    },
    colProps: {
      span: 8,
    },
  },
];

export const formDescSchema = [
  {
    field: 'traceId',
    label: 'TraceId'
  },
  {
    field: 'jobName',
    label: '任务名称'
  },
  {
    field: 'jobGroup', 
    label: '任务组名',
    render: (curVal, data) => {
      return render.renderDict(curVal, 'sys_job_group')
    },
  },
  {
    field: 'invokeTarget',
    label: '调用目标'
  },
  {
    field: 'jobMessage',
    label: '日志信息',
    contentStyle: {             
      maxWidth: '500px',
      wordBreak: 'break-all',
      wordWrap: 'break-word'
    },
    span: 1,
    render: (curVal, data) => {
      return `${data.jobGroup}-${curVal}`;
    },
  },
  {
    field: 'exceptionInfo',
    label: '异常信息',
    render: (curVal, data) => {
      return render.renderHtml(curVal, {
        minHeight: '50px'
      });
    },
    contentStyle: {             
      maxWidth: '500px',
      wordBreak: 'break-all',
      wordWrap: 'break-word'
    }
  },
  {
    field: 'status',
    label: '状态',
    render: (curVal, data) => {
      const color = curVal == '1' ? 'red' : curVal == '0'? 'green': 'gray';
      return render.renderTag(render.renderDict(curVal, 'quartz_status'),color)
    },
  },
  {
    field: 'createdAt',
    label: '创建时间'
  }
];
